package com.music.entity;

import java.util.List;

/**
 * 工具类
 * @author Administrator
 *
 */
public class Tool {
	/**
	 * 计算总数量
	 * @param shoppingCarts
	 * @return
	 */
	public static int countSum(List<ShoppingCart> shoppingCarts){
		int count=0;
		for (ShoppingCart shoppingCart : shoppingCarts) {
			count+=shoppingCart.getQuantity();
		}
		return count;
	}
	
	
	/**
	 * 计算总价格
	 * @param shoppingCarts
	 * @return
	 */
	public static double countPrice(List<ShoppingCart> shoppingCarts){
		double count=0;
		for (ShoppingCart shoppingCart : shoppingCarts) {
			count+=shoppingCart.getAlbum().getPrice()*shoppingCart.getQuantity();
		}
		return count;
	}
}
